//
//  ViewController.m
//  ZImageLoopViewDemo
//
//  Created by Meniny on 14/12/23.
//  Copyright (c) 2014年 Zero. All rights reserved.
//

#import "ViewController.h"
#import "ZImageLoopView.h"

@interface ViewController () <ZImageLoopViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    NSMutableArray *imageArr = [NSMutableArray array];
    for (int i = 0; i < 5; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", i + 1]];
        [imageArr addObject:image];
    }
    
    ZImageLoopView *loopView = [[ZImageLoopView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, self.view.bounds.size.width * 9 / 16)];
    loopView.imageLoopViewDelegate = self;
    loopView.imageArr = imageArr;
    loopView.loopTime = 3.0;

    [self.view addSubview:loopView];
}

- (void)imageLoopView:(ZImageLoopView *)imageLoopView didClickImageAtIndex:(NSInteger)index {
    NSLog(@"%zd", index);
}

- (UILabel *)imageLoopView:(ZImageLoopView *)imageLoopView titleLabelForImageAtIndex:(NSInteger)index {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, imageLoopView.bounds.size.height - 32, imageLoopView.frame.size.width, 32)];
    label.text = @"TitleForImage";
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.alpha = 0.6;
    label.backgroundColor = [UIColor blackColor];
    
    return label;
}

@end
